package com.github.postsanf.yinian.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.github.postsanf.yinian.R;
import com.github.postsanf.yinian.utils.ImageOptHelper;

import java.util.List;

public class StealPhotosBigAdapter extends PagerAdapter {
    private List<String> mList;
    private Context mContext;

    public StealPhotosBigAdapter(Context mContext, List<String> mList) {
        this.mContext = mContext;
        this.mList = mList;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object obj) {
        return view == obj;
    }

    @Override
    public Object instantiateItem(ViewGroup container, final int position) {
        View view = LayoutInflater.from(mContext).inflate(
                R.layout.yn_item_stealbig, null);
        ImageView iv_stealphoto_show = (ImageView) view.findViewById(R.id.iv_stealphoto_show);
        ImageOptHelper.showFrescoStatus(mList.get(position), iv_stealphoto_show, mContext);
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        // 这里不需要做任何事情
        ((ViewPager) container).removeView((View) object);
    }

}